package com.xinjiang.electricpower.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xinjiang.electricpower.domain.PsmWorkOrder;
import com.xinjiang.electricpower.domain.vo.PsmWorkOrderVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author feizhao
 * @date 2022/11/9
 * @apiNote 派工单Mapper接口
 */
public interface PsmWorkOrderMapper extends BaseMapper<PsmWorkOrder> {

    @Select("select " +
            "pwo.id," +
            "pwo.create_time," +
            "pwo.work_no," +
            "pwo.work_name," +
            "pwo.business_type," +
            "su1.nick_name as responsible," +
            "su2.nick_name as create_user," +
            "su3.nick_name as approve_user," +
            "pwo.cons_no," +
            "pwo.contact_way," +
            "pwo.status" +
            " from psm_work_order pwo " +
            "left join sys_user su1 on pwo.responsible = su1.user_name " +
            "left join sys_user su2 on pwo.create_user = su2.user_name " +
            "left join sys_user su3 on pwo.approve_user = su3.user_name " +
            " ${ew.customSqlSegment} ")
    List<PsmWorkOrder> findPsmWorkOrders(@Param("ew") QueryWrapper<PsmWorkOrderVO> wrapper);
}
